package com.zxbg.dao;

import com.zxbg.domain.NavMenu;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface NavMenuDao {
    @Select("select * from nav_menu where tenant_id = #{tenant_id} order by `order`")
    public List<NavMenu> getAllNavMenu(Integer tenant_id);

    @Insert("insert into nav_menu values(null, #{create_time}, #{menu_name_zh}, #{menu_name_en}, #{visit_url}, #{tenant_id}, #{status}, #{order}, #{creator_id}, 0)")
    public int addNavMenu(NavMenu navMenu);

    @Update("update nav_menu set `status` = #{status} where menu_id = #{menu_id}")
    public int changeStatus(@Param("menu_id") Integer menu_id, @Param("status") Integer status);

    @Update("update nav_menu set menu_name_zh = #{menu_name_zh}, menu_name_en = #{menu_name_en}, visit_url = #{visit_url}, `status` = #{status}, `order` = #{order} where menu_id = #{menu_id}")
    public int editNavMenu(NavMenu navMenu);

    @Delete("delete from nav_menu where menu_id = #{menu_id}")
    public int deleteNavMenu(Integer menu_id);

    @Select("select * from nav_menu where (menu_name_zh like #{key} or menu_name_en like #{key}) and tenant_id = #{tenant_id}")
    public List<NavMenu> getNavMenuByKey(@Param("key") String key, @Param("tenant_id") Integer tenant_id);

    @Select("select * from nav_menu where status = 1 and tenant_id = #{tenant_id} order by `order`")
    public List<NavMenu> getActiveNavMenu(Integer tenant_id);
}
